<!-- row -->
<div class="row">
    <!-- NEW COL START -->
    <article class="col-sm-12 col-md-12 col-lg-12">

        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget" id="{$Think.MODULE_NAME}-{$Think.CONTROLLER_NAME}-{$Think.ACTION_NAME}-2" data-widget-colorbutton="false" data-widget-editbutton="false" data-widget-custombutton="false">

            <!-- widget div-->
            <div style="border-top: solid 1px #ccc;">

                <!-- widget edit box -->
                <div class="jarviswidget-editbox">
                    <!-- This area used as dropdown edit box -->

                </div>
                <!-- end widget edit box -->

                <!-- widget content -->
                <div class="widget-body">
                        <form action="{:U('passage/add')}" id="add-form" method="post" class="form-horizontal">
                                <present name="data">
                                <input type="hidden" value="{$data.id}" name="id"/>
                                </present>
                                <fieldset>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">文章名称</label>
                                        <div class="col-md-8">
                                            <input type="text" name="title" value="{$data.title}" placeholder="" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">阅读量</label>
                                        <div class="col-md-8">
                                            <input type="text" name="readnum" value="{$data.readnum}" placeholder="" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">赞数量</label>
                                        <div class="col-md-8">
                                            <input type="text" name="zannum" value="{$data.zannum}" placeholder="" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">积分</label>
                                        <div class="col-md-8">
                                            <input type="text" name="score" value="{$data.score}" placeholder="" class="form-control">
                                        </div>
                                    </div>
                                    <!-- <div class="form-group">
                                        <label class="col-md-2 control-label">图片</label>
                                        <div class="col-md-8 pic-div">
                                            <div style="border: none" class="input-group smart-form form-control">
                                                <section>
                                                    <label style="margin-left: -12px" for="file" class="input input-file">
                                                        <div class="button">
                                                            <input type="file" id="tmpfile" name="tmpfile"  multiple="true" />上传
                                                        </div>
                                                        <input type="text"  value="{$data.img}"  name="img">
                                                    </label>
                                                </section>
                                            </div>
                                        </div>
                                        <div class="col-md-2">
                                            <section class="up_img_show"></section>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-md-8">
                                           <div id="queue">
                                           </div>
                                        </div>
                                    </div>-->

                                    <div class="form-group">
                                        <label class="col-md-2 control-label">简介</label>
                                        <div class="col-md-10">
                                            <textarea rows="2" name="desc" placeholder="" class="form-control">{$data.desc}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">内容</label>
                                        <div class="col-md-10">
                                            <script type="text/plain" id="container" name="content">{$data.content}</script>
                                            
                                           <!--  <textarea rows="2" name="content" id="content" placeholder="" class="form-control">{$data.content}</textarea>-->
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">状态</label>
                                        <div class="col-md-10">
                                            <div class="">
                                                <!-- <label class="radio">
                                                     <input type="radio" name="status" <eq name="data.status" value="0" >checked="checked"</eq>  value="0" />
                                                     <i></i>待审</label>-->
                                                 <label class="radio">
                                                     <input type="radio" name="status" <eq name="data.status" value="1" >checked="checked"</eq> value="1" />
                                                     <i></i>上线</label>
                                                 <label class="radio">
                                                     <input type="radio" name="status" <eq name="data.status" value="2" >checked="checked"</eq> value="2" />
                                                     <i></i>下线</label>
                                             </div>
                                         </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-10 control-label"></label>
                                        <div class="col-md-2">
                                            <button type='submit'>确定</button>
                                        </div>
                                    </div>
                                </fieldset>
                        </form>
                </div>
            </div>

        </div>
    </article>
</div>
<script type="text/javascript" src="{$Think.config.SUB_PATH}ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="{$Think.config.SUB_PATH}ueditor/ueditor.all.js"></script>
    
<script type="text/javascript">
    //做一些清理工作
    $(".DTTT_dropdown").remove();
    $('.ui-dialog').remove();
    $('.datetimepicker').remove();
    
    var ue = UE.getEditor('container');
    
    
    $('#add-form').submit(function(){
        $(this).ajaxSubmit(function(data) {     
            if( data.status==200 ){
                window.history.go(-1);
            }else{
                alert(data.msg);
            }
        });
        return false;
    });
    
    var ajaxUploadUrl = "{:U("Common/upload")}";
    
    $('#tmpfile').uploadify({
        'formData'     : {
            'timestamp' : '<?php echo $timestamp;?>',
            'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
        },
        'swf'      : './js/uploadify/uploadify.swf',
        'uploader' : ajaxUploadUrl,
        'auto':true,
        'multi':false,
        'buttonText':"上传",
        'width':30,
        'onUploadSuccess' : function(file, data, response) {
            data = eval("("+data+")");;
            //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
            var img_url = data.content;
            $("#tmpfile").parent().siblings('input').eq(0).val(img_url);
        }
    });
    /**
     * 上传图片
     */
    /*function ajax_upload(files, obj){
        if(files == null) return;
        $(files).each(function(a,file){
            //提供一个可以取消的能力
            window.xhr = $.ajaxSettings.xhr();
            //事件函数
            var onProgressHandler = function(event){
                if(event.loaded) {
                    var howmuch = Math.floor((event.loaded / event.total) * 100);
                }else{
                      
                }
            };
            var onLoadedHandler = function(msg){
                
            };
            var onAbortHandler = function(){
            };
            //事件绑定
            xhr.upload.addEventListener('progress', onProgressHandler, false);
            xhr.upload.addEventListener('load', onLoadedHandler, false);
            xhr.upload.addEventListener('abort', onAbortHandler, false);

            xhr.onreadystatechange = function(event){
                if(event.target.readyState == 4 && event.target.status == 200){
                    var text = $.parseJSON(event.target.responseText);
                    logincheck(text);
                    if(text.status == 200){
                        $(obj).parent().nextAll('input').eq(0).val(text.content.pic_url);
                        var $div = $(obj).parents('.pic-div').next('div');
                        $div.find('.up_img_show').html('<a href="'+text.content.src+'" target="_blank"><img src="'+text.content.src+'" style="width:48px;" /></a><a href="javascript:void(0);" onclick="_clean_img(this);return false;" class="up_img_del"><i class="glyphicon glyphicon-remove"></i></a>');
                    }else{
                        warningBox(text.msg);
                    }
                }
            };
            xhr.open('post',ajaxUploadUrl + "&filename=" + file.name,true);
            //xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xhr.setRequestHeader("Content-Type", "multipart/form-data");
            xhr.send(file);
        });
        return false;
    }*/
</script>